#ifndef LUASCRIPT_H
#define LUASCRIPT_H
enum eScriptState
{
	eSS_WAITFRAME,
	eSS_WAITTIME,
	eSS_RUNING,
	eSS_NOTLOAD,
	eSS_DONE
};
class CLuaManager;
class CLuaDebugger;
struct lua_State;
class CLuaScript : public ILuaScript
{
public:
	CLuaScript();
	CLuaScript(CLuaManager* pManager);
	virtual ~CLuaScript();
	CLuaScript* Update(float fElapse);

	virtual bool CallFile(const char *szFileName);
	virtual bool CallString(const char *szString);
	virtual bool CallFunction(const char *szFuncName, SScriptParamObj *pIn, 
		int nInNum, SScriptParamObj *pRet, int nRetNum);
	virtual void ShowLuaCallStack() {}	
public:
	CLuaScript* GetNext();
	void SetNext(CLuaScript* pNext);
	const char* GetFileName();
private:
	void ResumeScript(float fParam);
	void FormatError();
	void OutputError(const char* szErrType);
	void LuaGetField(char* pKey, void* pRet, int nType);
private:
	eScriptState m_eState;
	int m_nWaitFrame;
	float m_fCurTime;
	CLuaScript* m_pNext;
	lua_State* m_pTheadState;
	char m_arrLastErr[256];
	CLuaManager* m_pManager;
	char m_arrFileName[256];
	CLuaDebugger* m_pDebugger;
};
#endif